import Service from '@/common/service/service';
import {
    GET_FIND_INFO,
    GET_ORGANIZATION_LIST,
    GET_ORGANIZATION_SEARCH,
    POST_DELETE_ORGANIZATION,
    POST_ORGANIZATION_DISABLE,
    POST_UPDATE_ORGANIZATION
} from "@/views/system/organization/organization-const";
import ResponseModel from "@/common/model/response.model";
import TreeNodeModel from "@/views/system/organization/model/tree-node.model";

export default class OrganizationService {
    /**
     * 查询全部组织机构
     */
    public static getOrganizationList(orgId: number): Promise<ResponseModel<TreeNodeModel>> {
        return Service.post(GET_ORGANIZATION_LIST, orgId);
    };

    /**
     * 查询组织机构信息
     */
    public static findInfo(orgId: number): Promise<ResponseModel<TreeNodeModel>> {
        return Service.post(GET_FIND_INFO,orgId);
    };

    /**
     * 新增/修改组织机构
     */
    public static saveOrUpdate(params: TreeNodeModel): Promise<ResponseModel> {
        return Service.post(POST_UPDATE_ORGANIZATION, params);
    };

    /**
     * 删除组织机构
     */
    public static OrganizationDelete(orgId: number): Promise<ResponseModel> {
        return Service.post(POST_DELETE_ORGANIZATION,orgId);
    };

    /**
     * 停用组织机构(及子机构)
     */
    public static disableOrg(orgId:number): Promise<ResponseModel> {
        return Service.post(POST_ORGANIZATION_DISABLE,orgId);
    };

    /**
     * 搜索
     */
    public static getSearch(searchText: string): Promise<ResponseModel<TreeNodeModel[]>> {
        return Service.get(GET_ORGANIZATION_SEARCH, searchText);
    };

}
